package com.kohler.blog.base.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.kohler.blog.base.enums.EStatus;
import com.kohler.blog.base.globalConf.Constants;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
 * Entity 基类
 *
 */
@Data
@SuppressWarnings("rawtypes")
public class SuperEntity<T extends Model> extends Model {

    /**
     * 唯一UID
     */
    @TableId(value = "uid", type = IdType.ASSIGN_ID)
    private String uid;

    /**
     * 状态 0: 禁用  1: 启用
     */
    private int status;

    /**
     * 创建时间
     */
    @DateTimeFormat(pattern = Constants.DATE_FORMAT_YYYY_MM_DD_HH_MM_SS)
    @JsonFormat(pattern = Constants.DATE_FORMAT_YYYY_MM_DD_HH_MM_SS)
    @TableField(fill = FieldFill.INSERT)
    private Date gmtCreate;

    /**
     * 更新时间
     */
    @DateTimeFormat(pattern = Constants.DATE_FORMAT_YYYY_MM_DD_HH_MM_SS)
    @JsonFormat(pattern = Constants.DATE_FORMAT_YYYY_MM_DD_HH_MM_SS)
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date gmtModified;

    public SuperEntity() {
        this.status = EStatus.ENABLED;
    }
}
